package com.thf.message.sender;


import com.thf.model.Email;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/message")
public class MessageSend {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/send")
    public void send(String email,String username,String pass,String rk){
//        System.out.println("email-----------------"+email);
//        System.out.println("email-----------------"+username);
//        System.out.println("email-----------------"+pass);
//        System.out.println("email-----------------"+rk);
        Email emailModel = new Email();
        emailModel.setTo(email);
        emailModel.setSubject("系统消息");
        emailModel.setContent("系统消息已经为您创建了用户，登录名为："+username+",密码为："+pass);
        rabbitTemplate.convertAndSend("thfTopicExchange", rk, emailModel);
    }
}
